//配置的基本信息
//易汉语平台
//时间：2019.03.05
//作者：xianghai
//网站的接口配置
var api = {
    inter: "http://192.168.3.128/han3/api/user.php",
    startUp: 'api/user.php',
    adminInter: 'api/admin.php',
    login: 'api/admin.php', //登录接口
    school: "api/school.php", //学校查询
    codeApi: "api/coList.php", //激活码列表查询
    reasource: "api/resource.php", //资源列表数据
    edition: "api/edition.php", //版本列表数据
    bbs: "api/bbs.php", //公告信息接口
    uploadFile: 'api/tiku.php'//上传文件接口

};
//定义浏览器类型
var browser=getBrowser();

//js将php时间戳转换成格式化日期
function to_date(phpstr) {
    str = parseInt(phpstr) * 1000;//将php时间戳转化为整形并乘以1000
    var newDate = new Date(str);
    var year = newDate.getUTCFullYear();//取年份
    var month = newDate.getUTCMonth() + 1;//取月份
    var nowday = newDate.getUTCDate();//取天数
    var hours = newDate.getHours();//取小时
    var minutes = newDate.getMinutes();//取分钟
    var seconds = newDate.getSeconds();//取秒
    if (phpstr == null) {
        return "暂无记录";
    } else if (phpstr == "0") {
        return "";
    } else {
        return year + "-" + month + "-" + nowday + " " + hours + ":" + minutes + ":" + seconds;//拼接 2017-2-21 12:23:43
    }

}

//将毫秒转换成几天
function formatDuring(mss) {

    var days = parseInt(mss / (1000 * 60 * 60 * 24));
    var hours = parseInt((mss % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    var minutes = parseInt((mss % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = (mss % (1000 * 60)) / 1000;
    if (days > 0) {
        return days + " 天 " + hours + ": " + minutes;
    } else {
        if (hours > 0) {
            return hours + ":" + minutes;
        } else {
            return minutes + "分钟";
        }
    }
}

//将秒转换成几天
function secondToDay(mss) {

    var days = parseInt(mss / (60 * 60 * 24));
    var hours = parseInt((mss % (60 * 60 * 24)) / (60 * 60));
    var minutes = parseInt((mss % (60 * 60)) / 60);
    var seconds = mss % 60;
    if (days > 0) {
        return days + " 天 ";
    } else {
        if (hours > 0) {
            return hours + ":" + minutes;
        } else {
            return minutes + "分钟";
        }
    }
}

//获取当前的时间
function getDate() {  //获取当前时间

    var myDate = new Date();

    var y = myDate.getFullYear();    //获取完整的年份

    var m = myDate.getMonth() + 1;       //获取当前月份(0-11,0代表1月)
    if (m < 10) {
        m = "0" + m;
    }

    var d = myDate.getDate();        //获取当前日(1-31)

    if (d < 10) {

        d = "0" + d;

    }
    var mytime = y + "-" + m + "-" + d;
    endTime = mytime;
    d = d - 9;
    startTime = y + "-" + m + "-" + d;

}
//第几册
function changeUnit(val) {
    return parseInt(val) + 1;

}
//判断是否为iE浏览器
function isIE() {
    if (!!window.ActiveXObject || "ActiveXObject" in window) {
        return true;
    } else {
        return false;
    }
}
//获取浏览器版本兼容处理
function getBrowser()
{
    var browser=navigator.userAgent;
    if(browser.indexOf("MSIE")>0) {
        return "MSIE";
    }
    if(isFirefox=browser.indexOf("Firefox")>0){
        return "Firefox";
    }
    if(isSafari=browser.indexOf("Safari")>0) {
        return "Safari";
    }
    if(isCamino=browser.indexOf("Camino")>0){
        return "Camino";
    }
    if(isMozilla=browser.indexOf("Gecko/")>0){
        return "Gecko";
    }
    if (!!window.ActiveXObject || "ActiveXObject" in window) {

        return "IE";
    }

}